//
//  QiYeLeiXingView.m
//  EnterpriseEdition
//
//  Created by ypj on 2021/10/9.
//

#import "QiYeLeiXingView.h"

@implementation QiYeLeiXingView
-(instancetype)initWithFrame:(CGRect)frame withTag:(NSInteger)selectTag{
  self=[super initWithFrame:frame];
    if (self) {
        self.selectTag=selectTag;
       [self createButtonView];
    }
    return self;
}
-(void)createButtonView{
    self.backgroundColor=White_Color;
    NSMutableArray *titleArray =[NSMutableArray arrayWithArray:@[@" 租赁公司",@" 出租车",@" 企业招募"]];
    
    self.bgView = [[UIView alloc] initWithFrame:CGRectMake(90, 0, ScreenWidth-100, 58)];
    UILabel *titleLb = [[UILabel alloc] initWithFrame:CGRectMake(16, 26, 70, 28)];
    titleLb.text = @"企业类型";
    titleLb.font = [UIFont systemFontOfSize:15.0];
    [self addSubview:titleLb];
    CGFloat buttonWidth = self.bgView.width / 3.0;
    
    self.typeLb = [[UILabel alloc] initWithFrame:CGRectMake(ScreenWidth - 86, 26, 80, 28)];
    self.typeLb.text = @"租赁公司";
    self.typeLb.textColor = gray666_color;
    self.typeLb.font = [UIFont systemFontOfSize:12.0];
    [self addSubview:self.typeLb];
    int x = 0;

    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(16, 57, ScreenWidth-32, 1)];
     lineView.backgroundColor=[UIColor colorWithHexString:@"#DFDFDF"];
    [self addSubview:lineView];
    for (int i = 0; i < 3; i ++) {
        int y = 26;
            UIButton *button =[UIButton buttonWithType:UIButtonTypeCustom];
            [button setTitle:titleArray[i]  forState:UIControlStateNormal];
             button.titleLabel.font = [UIFont systemFontOfSize:14.0];
        
            [button setTitleColor:gray666_color forState:UIControlStateNormal];
            [button setImage:Image(@"small_unSelect_icon") forState:UIControlStateNormal];
             button.frame = CGRectMake(x, y, buttonWidth, 26);
             button.tag = i + 830;
            [button addTarget:self action:@selector(selectedAction:) forControlEvents:UIControlEventTouchUpInside];
            [self.bgView addSubview:button];
            if (button.tag == self.selectTag){
                 self.tmpBtn = button;
                [self.tmpBtn setImage:Image(@"small_select_icon") forState:UIControlStateNormal];
            }
        x = MaxX(button);
        }
   [self addSubview:self.bgView];

}

-(void)selectedAction:(UIButton *)sender
{
    if (self.tmpBtn == sender){
        [self.tmpBtn setImage:Image(@"small_unSelect_icon") forState:UIControlStateNormal];
    } else {
        [self.tmpBtn setImage:Image(@"small_select_icon") forState:UIControlStateNormal];

    }
     self.tmpBtn = sender;
     self.ToRefreshButtonTable(sender.tag);
}

@end
